package com.lovo.after.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.after.entity.GoodsEntity;
import com.lovo.after.mapper.GoodsMapper;
import com.lovo.after.service.IGoodsService;
import org.springframework.stereotype.Service;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> implements IGoodsService {
    @Override
    public void updateStatus(long goodsId,int status) {
        GoodsEntity goods = baseMapper.selectById(goodsId);
        goods.setStatus(status);
        baseMapper.updateById(goods);
    }

    @Override
    public void addNum(String goodsNo, int num) {
        QueryWrapper qw = new QueryWrapper<>();
        qw.eq("goods_no",goodsNo);
        GoodsEntity goods = baseMapper.selectOne(qw);
        goods.setNum(goods.getNum()+num);
        baseMapper.updateById(goods);
    }
}
